<?php 
session_start();	//开启session会话
include '../public/common/mysql_connect.php';
include '../public/common/function.php';
$username=$_POST['username'];
$password=$_POST['password'];
$repassword=$_POST['repassword'];
$fcode=$_POST['fcode'];
$vcode=$_SESSION['vcode'];

// echo $_SESSION['vcode'];exit;
if($fcode==$vcode){
	if($password==$repassword){
		$sql="insert into user(username,password) values('{$username}','{$password}')";
		if(mysqli_query($conn,$sql)){
			// $_SESSION['home_username']=$username;
			// $_SESSION['home_userid']=mysql_insert_id();
			echo "<script>alert('恭喜你注册成功！！！')</script>";
			echo "<script>location='login.php'</script>";
		}
	}
	else{
		echo "<script>alert('两次密码输入不一致')</script>";
		echo "<script>location='register.php'</script>";
	}
}
else{
	echo "<script>alert('验证码错误')</script>";
	echo "<script>location='register.php'</script>";
}
?>